﻿using System;

namespace Entities
{
    [Serializable]
    public class Ticket
    {
        private int ticketID;
        private int orderID;
        private int fromStation;
        private int toStation;
        private int fromStationNumber;
        private int toStationNumber;
        private int scheduleID;
        private int seatNo;
        private int coachTypeID;
        private float fare;
        private int status;
        private DateTime date;
        private DateTime expirationDate;

        public Ticket()
        { }
        public Ticket(int ticketID, int orderID, int fromStation, int toStation, int fromStationNumber, int toStationNumber, int scheduleID, int seatNo, int coachTypeID, float fare, int status, DateTime date, DateTime expirationDate)
        {
            this.ticketID = ticketID;
            this.orderID = orderID;
            this.fromStation = fromStation;
            this.toStation = toStation;
            this.fromStationNumber = fromStationNumber;
            this.toStationNumber = toStationNumber;
            this.scheduleID = scheduleID;
            this.seatNo = seatNo;
            this.coachTypeID = coachTypeID;
            this.fare = fare;
            this.status = status;
            this.date = date;
            this.expirationDate = expirationDate;
        }
        public int TicketID
        {
            get { return this.ticketID; }
            set
            {
                if (value < 0)
                    throw new Exception("ticketID not allow nullvalue.");
                this.ticketID = value;
            }
        }
        public int OrderID
        {
            get { return this.orderID; }
            set { this.orderID = value; }
        }
        public int FromStation
        {
            get { return this.fromStation; }
            set { this.fromStation = value; }
        }
        public int ToStation
        {
            get { return this.toStation; }
            set { this.toStation = value; }
        }
        public int FromStationNumber
        {
            get { return this.fromStationNumber; }
            set { this.fromStationNumber = value; }
        }
        public int ToStationNumber
        {
            get { return this.toStationNumber; }
            set { this.toStationNumber = value; }
        }
        public int ScheduleID
        {
            get { return this.scheduleID; }
            set { this.scheduleID = value; }
        }
        public int SeatNo
        {
            get { return this.seatNo; }
            set { this.seatNo = value; }
        }
        public int CoachTypeID
        {
            get { return this.coachTypeID; }
            set { this.coachTypeID = value; }
        }
        public float Fare
        {
            get { return this.fare; }
            set { this.fare = value; }
        }
        public int Status
        {
            get { return this.status; }
            set { this.status = value; }
        }

        public DateTime Date
        {
            get { return date; }
            set { date = value; }
        }

        public DateTime ExpirationDate
        {
            get { return expirationDate; }
            set { expirationDate = value; }
        }

        public override string ToString()
        {
            return this.ticketID + "; " + this.orderID + "; " + this.fromStation + "; " + this.toStation + "; " + this.fromStationNumber + "; " + this.toStationNumber + "; " + this.scheduleID + "; " + this.seatNo + "; " + this.coachTypeID + "; " + this.fare + "; " + this.status + "; ";
        }
        public override bool Equals(Object obj)
        {
            Ticket me = (Ticket)obj;
            bool ret = this.TicketID.Equals(me.TicketID);
            return ret;
        }
        public override int GetHashCode()
        {
            return this.TicketID.GetHashCode();
        }

    }
}